package com.cbtx.tablet.adapter

import android.widget.ImageView
import android.widget.LinearLayout
import com.bumptech.glide.Glide
import com.cbtx.tablet.R
import com.cbtx.tablet.bean.MainMenuBean2
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

/**
 * author : joker.peng
 * e-mail : joker@fiture.com
 * date   : 2021/7/6 11:49 PM
 * desc   :
 */
class MainMenuAdapter2 : BaseQuickAdapter<MainMenuBean2, BaseViewHolder> {

    constructor() : super(R.layout.item_main_menu)

    override fun convert(helper: BaseViewHolder, item: MainMenuBean2) {
        val ivIcon: ImageView = helper.getView(R.id.iv_main_menu)

        if(helper.layoutPosition == 0){
            var params = ivIcon.layoutParams as LinearLayout.LayoutParams
            params.setMargins(24, 12, 24, 0)
            ivIcon.layoutParams = params
        }

        if (helper.layoutPosition === 0) {
            Glide.with(context).load(item.iconId).into(ivIcon)
        } else {
            Glide.with(context).load(item.iconUrl).into(ivIcon)
        }
    }
}